#define DEBUG
#include <cstdio>

using namespace std;

int fact[10];

int solve(int o, int *c, int n, int cnt, int sum, long long q) {
  if (o<9) {
    int ret=0;
    for (int i=0; i<=n; i++) {
      c[o]+=i;
      ret += solve(o+1, c, n-i, cnt, sum+i*o, q);
      q |= q<<o;
      c[o]-=i;
    }
    return ret;
  } else if (o==9) {
    c[o]+=n;
    for (int i=1; i<=n; i++) {
      q |= q<<o;
    }
    int ret=solve(o+1, c, 0, cnt, sum+n*o, q);
    c[o]-=n;
    return ret;
  } else {
    if (sum%2==0 && ((q>>(sum/2))&1)) {
      int ret=fact[cnt];
      for (int i=0; i<10; i++) {
	ret = ret/fact[c[i]];
      }
      return ret;
    } else {
      return 0;
    }
  }
}

int calc(int n) {
  n++;
  static int a[10], c[10];
  a[0]=0;
  for (int i=1; i<=n; i=i*10) {
    a[++a[0]] = n/i%10;
  }

  int ret=0;
  for (int i=0; i<10; i++) {
    c[i] = 0;
  }

  for (int i=1; i<a[0]; i++) {
    for (int j=1; j<10; j++) {
      ret += solve(0, c, i-1, i-1, j, 1|(1<<j));
    }
  }

  for (int i=1; i<a[a[0]]; i++) {
    ret += solve(0, c, a[0]-1, a[0]-1, i, 1|(1<<i));
  }

  long long q=1;
  int sum=0;
  for (int j=a[0]; j>1; j--) {
    q |= q<<a[j];
    sum += a[j];
    for (int k=0; k<a[j-1]; k++) {
      ret += solve(0, c, j-2, j-2, sum+k, q|(q<<k));
    }
  }
  return ret;
}

int main() {
#ifdef DEBUG
  freopen("3362.in", "r", stdin);
  freopen("3362.out", "w", stdout);
#endif

  fact[0]=1;
  for (int i=1; i<=10; i++) {
    fact[i] = fact[i-1]*i;
  }

  int a, b;
  scanf("%d %d", &a, &b);

  printf("%d", calc(b)-calc(a-1));

  fclose(stdin);
  fclose(stdout);
  return 0;
}
